
//判断是否是微信浏览器
function isWeiXin(){
    var ua = window.navigator.userAgent.toLowerCase();
    if(ua.match(/MicroMessenger/i) == 'micromessenger'){
        return true;
    }else{
        return false;
    }
}

(function(){
	route.setModule({
		'#': 'home.html',							//首页
        '#home': 'home.html',						//首页
		'#curriculum':'curriculum.html',		//课程
		'#task' : 'task.html',					//任务预告
		'#review' : 'review.html',				//往期回顾
    });
	
	route.setup({
		module: '#home',
		title: '',
		data: null,
		timeout: 3000,
		onAfter: function(){
			console.log('默认前置');
		},
		onProgress: function(){
			console.log('默认载入中');
		},
		onBefore: function(){
			console.log('默认后置');
		},
		onSuccess: function( html){
            $('.IndexHome').empty().append(html);
			console.log('默认成功');
		},
		onError: function(){
			console.log('默认失败');
		},
		onTimeout: function(){
			console.log('默认超时');
		}
	});

	route.go({
		module: location.hash.split('?')[0] || '#home',
		history: false
	});

	$(document).on( 'tap', '.R-go', function(){
		var m = $(this).attr('path');
		try{
			eval( "var data = "+$(this).attr('path-data'));
		}catch(e){
			console.error( e.message);
		}
		if( m){
			route.status = 'forward';
			route.go({ module: m, data: data || {}});
		}else{
			console.error( 'm 为空！');
		}
	}).on( 'tap', '.R-back', function(){
		route.back();
	}).on( 'tap', '.R-forward', function(){
		route.forward();
	});
	
})();
